home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / amigae.july.archive / 000023_crash!minyos.xx….OZ.AU!s924723_Mon, 12 Jul 93 05:41:08 PST.msg < prev    next >
Text File  |  1993-08-31  |  3KB  |  103 lines

  1. Received: by bkhouse.cts.com (V1.16/Amiga)
  2.     id AA00000; Mon, 12 Jul 93 05:41:08 PST
  3. Received: from peladon.rmit.OZ.AU by crash.cts.com with smtp
  4.     (Smail3.1.28.1 #15) id m0oFN78-00007WC; Mon, 12 Jul 93 05:36 PDT
  5. Received: from minyos.xx.rmit.OZ.AU by peladon.rmit.OZ.AU with SMTP id AA19977
  6.   (5.65c/IDA-1.4.4 for <amigae@bkhouse.cts.com>); Mon, 12 Jul 1993 22:36:05 +1000
  7. Received: by minyos.xx.rmit.OZ.AU
  8. Date: Mon, 12 Jul 93 22:35:50 EST
  9. Message-Id: <9307121235.21423@minyos.xx.rmit.OZ.AU>
  10. From: s924723@minyos.xx.rmit.OZ.AU (Son Huu Le)
  11. To: amigae@bkhouse.cts.com
  12. Subject: Optimising_E
  13.  
  14.  
  15. (Profiler output and drool deleted :)
  16.  
  17. Boyerm.e probably suffered from a low buffer size input, which reminds me,
  18. what are the proper arguments for the DOS function SetVBuf()? The DOS
  19. manual says it accepts 4 arguments, E only accepts 3!?
  20.  
  21. Okay, so the boyerm.e example wasn't a very good as it relied on DOS calls,
  22. but I still say E is slower and would benefit from a good optimizer. While
  23. I was debugging my programs, I noticed that E always(?) used MOVE.L x(A5),D0
  24. for variable storage/retrieval. In a tight loop, a MOVE.L x(AN),D0
  25. will cost more cycle time than a MOVE.L D1,D0. Since E doesn't touch the
  26. other data registers often, it would help speed time greatly if you could
  27. use them.
  28.  
  29. For a better example(?) I coded the following short |ittle program, which is
  30. small and relies on no external calls (except for outputting of result at
  31. the end which btw, if left out under SAS/C, makes the program run under
  32. 1 sec - clever optimiser :)
  33.  
  34. E:
  35.  
  36. PROC main()
  37. DEF x=0, y=0
  38.     WHILE x<500000
  39.         x++
  40.         y:=y+x
  41.     ENDWHILE
  42.     WriteF('\d\n',y)
  43. ENDPROC
  44.  
  45. Disassembly of main loop:
  46. loop:
  47.     MOVE.L    -4(A5),D0
  48.     CMPI.L    #500000,D0
  49.     BGE    out
  50.     MOVE.L    -4(A5),D0    ; What's this for?! (;
  51.     ADDQ.L    #1,-4(A5)
  52.     MOVE.L    -8(A5),D0
  53.     ADD.L    -4(A5),D0
  54.     MOVE.L    D0,-8(A5)
  55.     BRA    loop
  56.  
  57. C:
  58.  
  59. #include <stdio.h>
  60.  
  61. void main()
  62. {
  63.     int x=0, y=0;        /* Direct port - bare minimum change */
  64.     while (x<500000) {
  65.         x++;
  66.         y=y+x;
  67.     }
  68.     printf("%d\n",y);
  69. }
  70.  
  71. Disassembly of main loop:
  72. loop:
  73.     ADDQ.L    #1,D7
  74.     ADD.L    D7,D6        ; SAS/C might be expensive, but look at this!
  75.     CMPI.L    #500000,D7
  76.     BLT.S    loop
  77.  
  78. Time results:
  79. ~~~~~~~~~~~~
  80. (On an Amiga 2000 with 2mb fast, 1mb chip)
  81. (Faster machines might need to alter the counter for meaningful results)
  82.  
  83. 11.STAT-RAM:> timex test_c
  84. 446198416
  85. Ticks:429 -> Secs:8.58 -> Time:0h0m8s
  86.  
  87. 11.STAT-RAM:> timex test_e
  88. 446198416
  89. Ticks:1224 -> Secs:24.48 -> Time:0h0m24s
  90.  
  91.  
  92. Although I don't expect E to outperform a commercial C product, using
  93. spare data registers would increase E's performance tremendously.
  94.  
  95. One last suggestion.. how about making some E functions (such as WriteF)
  96. more assembling friendly, so you can use certain E functions in the middle
  97. of an assembly code? ie. it uses only the upper data/address registers (4-7)
  98. and leaves the lower ones intact.
  99.  
  100. Regards..
  101. Son Le
  102.  
  103. PS. Wouter, your address <Wouter@alf.let.uva.nl> bounced.